using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	[TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "admin" })]
	public class CarEventsController : BaseController
	{
		private readonly ICarEventsServer _carEventsServer;
		public CarEventsController(ICarEventsServer carEventsServer)
		{
			_carEventsServer = carEventsServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add(RequestCarEventsDto dto)
		{
			var uase = _account;
			return Send(await _carEventsServer.AddAsync(dto,uase.AId));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Delete(RequestCarEventsDto dto)
		{
			return Send(await _carEventsServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update(RequestCarEventsDto dto)
		{
			return Send(await _carEventsServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param></param>
		/// <returns></returns>
		///
		[HttpGet]
		public async Task<IActionResult> Pagination(int page,int limit)
		{
			return Send(await _carEventsServer.PaginationAsync(page,limit));
		}
        /// <summary>
        /// 查询进行中
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_underway(int page, int limit,string key)
        {
            return Send(await _carEventsServer.Get_underway(page, limit,key));
        }
        /// <summary>
        /// 查询结束的活动
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_js_underway(int page, int limit, string key)
        {
            return Send(await _carEventsServer.Get_js_underway(page, limit, key));
        }
    }
}
